Using Prolog as metalanguage for teaching programming language concepts

نویسنده

  • Henning Christiansen
چکیده

syntax trees are represented as Prolog terms but at the same time with an acceptable concrete appearance. A defining interpreter consists of the following predicates. program(program, final-storage) statement(statement, storage-before, storage-after) expression(expression, storage, integer) condition(condition, storage, ftrue, falseg) Some of the rules of this interpreter are shown in the following; the most important ones are for the if and while statements. Notice that we reuse the storage structure and auxiliaries from the previous example. program(P, Storage) :statement(P, [], Storage). statement((Var := Expression), L1, L2):expression(Expression, L1, Value), store(Var,Value,L1,L2). statement( (S1 ; S2), L1, L3):statement(S1, L1, L2), statement(S2, L2, L3). statement( if(Cond, Smt1, Stm2), L1, L2):condition(Cond, L1, Value), (Value = true -> statement(Stm1, L1, L2) ; statement(Stm2, L1, L2)). statement( while(Cond, Stm), L1, L2):condition(Cond, L1, Value), (Value = true -> statement( (Stm ; while(Cond, Stm)),L1,L2) ; L1=L2). expression(Variable, L, V):atom(Variable), fetch(Variable,V,L).

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

A Tiny Specification Metalanguage

A logic programming language with potential software engineering benefit is described. The language is intended as a specification language where the user specifies software functionality while ignoring efficiency. The goals of the language are: (1) a pure specification language – “what, not how”, (2) small size, and (3) a metalanguage – able to imitate and thus subsume other languages. The lan...

متن کامل

Meta Prolog Design and Implementation

Many researchers in the area of logic programming have recognized the limitations of logic languages such as Prolog and suggested a meta level approach as an alternative. Some of the main drawbacks cited are the control strategy, the presence of a single database, and the ad hoc extensions to the basic logic programming paradigm to allow the dynamic modification of the database. The MetaProlog ...

متن کامل

Meta-Programming in CLP(R)

A widely used property of Prolog is that it is possible to write Prolog programs to construct and manipulate other Prolog programs in a very general manner. Unfortunately , this property is not carried over to richer languages such as CLP(R) { the manipulation of CLP(R) programs in CLP(R) is quite limited. The reason is that the equality of terms in CLP(R) is not based on their syntactic struct...

متن کامل

Teaching Programming: Some Lessons from Prolog

Prolog (Programming in Logic) is the language of Artificial Intelligence (AI), and is renowned as a difficult language to learn. It embodies a programming paradigm that is radically different from the usual procedural languages, and even students who find other languages easy can struggle with Prolog. It is so different that students have to learn it as a completely new experience, even if they...

متن کامل

Logic Programming in Education: A Perspective on the State of Art

The interest in the use of Logic Programming in education stems from the great enthusiasm for Prolog that arose in the late seventies. However, Prolog is neither the purest Logic Programming language nor the easiest language for novices to come to terms with — but the opportunity to introduce very powerful ideas by teaching students to program in Prolog has been seized by many teachers at all l...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2001